#include "HGEHandle.h"
#include "common.h"
#include "hgeSprite.h"
#include <QWidget>
#include <iostream>
using namespace std;

void HGEHandle::setWidget(QWidget* _w)
{
    w = _w;
}

void HGEHandle::init()
{
	HTEXTURE t = hge->Texture_Load("Zombie_head.png");
	s = new hgeSprite(t, 0, 0, 53, 48);
	s->SetHotSpot(53/2, 48/2);

	mx = 100;
	my = 100;
	x  = 200;
	r  = 0.0f;
}

bool HGEHandle::render()
{
	hge->Gfx_BeginScene();
	hge->Gfx_Clear(0);
	get_instance()->s->RenderEx(get_instance()->mx, get_instance()->my, get_instance()->r);
	hge->Gfx_EndScene();
	return false;
}

bool HGEHandle::tick()
{
	HGEHandle* me = HGEHandle::get_instance();

	me->mx += me->x*hge->Timer_GetDelta();
	if (me->mx>500 || me->mx<=0)
	{
		me->x = -(me->x);
	}
	me->r += 0.05f;
	return false;
}

void HGEHandle::move_up()
{
	my -= 10;
}

void HGEHandle::move_down()
{
	my += 10;
}